@SpringBootTest
public class UserServiceTest {

    @Autowired
    private UserService userService;

    @Test
    public void testTransactionRollback() {
        User user = new User();
        user.setName("test_user");
        
        assertThrows(RuntimeException.class, () -> userService.createUser(user));
        // 检查数据库，user 应未被插入
    }
}